package cn.virens.web.components.beetl.menu;

import org.springframework.beans.factory.annotation.Autowired;

import cn.virens.web.components.beetl.menu.common.MenuProvider;
import cn.virens.web.components.beetl.tag.AbstractTag;

public class MenuTag extends AbstractTag<MenuTag> {
	private @Autowired MenuProvider mMenuProvider;

	@Override
	public void render() {
		try {
			String identity = String.valueOf(getAttributeValue("identity"));
			String uuid = String.valueOf(getAttributeValue("uuid"));

			String menuStr = mMenuProvider.renderMenus(uuid, identity);
			if (menuStr != null && !menuStr.isEmpty()) {
				ctx.byteWriter.writeString(menuStr);
			} else {
				ctx.byteWriter.writeString("菜单为空!");
			}
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
	}

}
